﻿from flask import Flask
from flask import render_template, flash, redirect

from form import LoginForm
from apps import app
#app = Flask(__name__)
#app.config.from_object('fileconfig')

@app.route('/')
def index():
    return render_template("index.html")
	
@app.route('/ni')	
def new_issue():
	return render_template("new_issue.html")
	
@app.route('/vi')
def view_issue():
	return render_template("view_issue.html")
	
@app.route('/mp')
def manage_projects():
	user_info = {'nick_name': 'abc', 'my_permisson': 'admin'}
	return render_template("manage_projects.html", user_info=user_info)
	
@app.route('/uc')
def user_center():
	user_info = {'name': 'yaozhikun', 'permisson': 'admin'}
	return render_template("user_center.html", user_info = user_info)
	
@app.route('/login', methods = ['GET', 'POST'])
def login():
    form = LoginForm()
    if form.validate_on_submit():
        flash('Login requested for OpenID="' + form.openid.data + '", remember_me=' + str(form.remember_me.data))
        return redirect('/test')
    return render_template('login.html',
        title = 'Sign In',
        form = form)

@app.route('/test')
def test():
    return "This is test!"

@app.route('/tongtong')
def test_html5():
    return render_template("test_html5.html")

@app.route('/test/template')
def test_template():
    user = {'nickname': 'Yzk'}
    posts = [
        {
            'author': { 'nickname': 'yzk' },
            'body': "Let's build a web called dt!"
        },
        {
            'author': { 'nickname': 'tyh' },
            'body': 'cool!'
        }
    ]
    return render_template("test_template.html", title='Home', user=user, posts=posts)

if __name__ == "__main__":
    app.run(host='0.0.0.0', port=80, debug=True)
